package com.sec.etech.org.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @version 1.0
 * @Author 褰寕鏄孿n * @Date 2021-07-30
 * @Description null
 */

@Data
@TableName("org_relation")
public class OrgRelation implements Serializable {

	private static final long serialVersionUID = 8187291847115558361L;

	/**
	 * ID
	 */
	@TableId(value = "id_")
	private String id;

	/**
	 * 组ID
	 */
	@TableField(value = "group_id_")
	private String groupId;

	/**
	 * 用户ID
	 */
	@TableField(value = "user_id_")
	private String userId;

	/**
	 * 1:默认组织，0：从组织
	 */
	@TableField(value = "is_master_")
	private Long isMaster;

	/**
	 * 角色ID
	 */
	@TableField(value = "role_id_")
	private String roleId;

	/**
	 * 状态：1启用，2禁用
	 */
	@TableField(value = "status_")
	private Long status;

	/**
	 * 类型：groupUser,groupRole,userRole,groupUserRole
	 */
	@TableField(value = "type_")
	private String type;

	/**
	 * 创建时间
	 */
	@TableField(value = "create_time_")
	private LocalDateTime createTime;

	/**
	 * 创建人
	 */
	@TableField(value = "create_by_")
	private String createBy;

	/**
	 * 更新时间
	 */
	@TableField(value = "update_time_")
	private LocalDateTime updateTime;

	/**
	 * 更新人
	 */
	@TableField(value = "update_by_")
	private String updateBy;

	/**
	 * 备注
	 */
	@TableField(value = "remark")
	private String remark;


	@TableField(exist = false)
	private String groupName;
	@TableField(exist = false)
	private String roleName;
	@TableField(exist = false)
	private String roleAlias;
	@TableField(exist = false)
	private String userName;
	@TableField(exist = false)
	private String userAccount;
	@TableField(exist = false)
	private String userDprtname;

	public String getPostName() {
		return String.format("%s-%s", this.getGroupName(), this.getRoleName());
	}

	public String getPostId() {
		return String.format("%s-%s", this.getGroupId(), this.getRoleId());
	}

	public void setGroupId(String groupId) {
		this.groupId = groupId;
	}

	public OrgRelation() {
	}

	public OrgRelation(String groupId, String userId, String roleId, String type) {
		this.groupId = groupId;
		this.userId = userId;
		this.roleId = roleId;
		this.type = type;
	}

}
